package com.zpc.rabbitmq.mqcallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
/**
 * 消息发送到交换机确认机制
 * @author Dhjie
 *
 */
public class MsgSendConfirmCallBack implements RabbitTemplate.ConfirmCallback{
	private static final  Logger logger=LoggerFactory.getLogger(MsgSendConfirmCallBack.class);

	public void confirm(CorrelationData correlationData, boolean ack, String cause) {
		 logger.info("MsgSendConfirmCallBack  , 回调id:" + correlationData);

	        if (ack) {
	            logger.info("消息生产成功");
	        } else {
	            logger.error("消息生产失败:" + cause + "\n重新发送");
	        }
	}

}
